package org.example.Tool.Component.tContentPanel;

import org.example.Tool.Component.AdjustIconBuilder;
import org.example.Tool.Component.ContentPanel;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;

public class EmptyPanel extends ContentPanel {
    public EmptyPanel(Dimension size, Image backImp){
        super(size);
        this.setOpaque(false);
        AdjustIconBuilder builder = new AdjustIconBuilder();
        background = new JLabel();
        builder.setComponent(this);
        builder.setImage(backImp.getScaledInstance(getWidth(),getHeight(),Image.SCALE_SMOOTH));
        builder.setConstrained(false);
        background.setBounds(0, 0, this.getWidth(), this.getHeight());
        background.setIcon(builder.of());
        background.setVisible(true);
        this.addComponentListener(new ComponentAdapter() {
            @Override
            public void componentResized(ComponentEvent e) {
                background.setBounds(
                        0,
                        0,
                        e.getComponent().getWidth(),
                        e.getComponent().getHeight()
                );

            }
        });
        this.add(background);
    }
}
